/* 交易页面管理模块 */
import { reqTradePage,reqMockAddress } from "@/api"
const actions = {
    // 交易页面请求
   async getTradePage({commit}){
        let result = await reqTradePage();
        if(result.code == 200){
            // 成功返回
            commit("SETTRADELIST",result.data);
        }
    },

    //mock数据：收获地址
   async getMyAddress({commit}){
        let result = await reqMockAddress();
        if(result.code == 200){
            commit("SETADDRESS",result.data);
        }
    }
}
const mutations = {
    SETTRADELIST(state,value){
        state.tradeList = value;
    },

    SETADDRESS(state,value){
        state.addressList = value;
    }
}
const state = {
    tradeList:{},
    addressList:{} || []
}
const getters  ={
    // 购物车商品数据
    detailArrayList(state){
        return state.tradeList.detailArrayList || {};
    } 
}

export default {
    namespaced: true,
    actions,
    mutations,
    state,
    getters
}